package cc.wsyw126.java.nowcoder.offer360;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

/**
 * Created by dp on 17/3/25.
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String s = sc.nextLine();
            String[] split = s.split(" ");
            int n = Integer.valueOf(split[0]), m = Integer.valueOf(split[1]);
            String s1 = sc.nextLine();
            String[] split1 = s1.split(" ");

            HashMap<Integer, Integer> result = new HashMap<>();
            List<Integer> list = new ArrayList<>();
            List<Integer> list1 = new ArrayList<>();
            for (int i = 0; i < m; i++) {
                int i1 = sc.nextInt();
                list.add(i1);
                list1.add(i1);
            }
            int begin = 0;
            for (int i = 0; i < split1.length; i++) {
                String s2 = split1[i];
                Integer integer = Integer.valueOf(s2);
                if (integer - begin >= 2) {
                    List<Integer> collect = list1.stream().filter(integer1 -> integer1 < integer).collect(Collectors.toList());
                    if (collect.size() != 0) {
                        doFilter(collect, begin + 1, result);
                        list1.removeAll(collect);
                    }
                }
                if (list1.size() == 0) {
                    break;
                }
                begin = integer;
            }
            if (list1.size() != 0) {
                for (Integer integer : list1) {
                    result.put(integer, begin + 1);
                }
            }
            for (Integer integer : list) {
                System.out.println(result.get(integer));
            }
        }
    }

    private static void doFilter(List<Integer> collect, int begin, HashMap<Integer, Integer> result) {
        if (collect.size() == 0) return;
        List<Integer> collect1 = collect.stream().filter(integer -> integer <= begin).collect(Collectors.toList());
        List<Integer> collect2 = collect.stream().filter(integer -> integer > begin).collect(Collectors.toList());

        for (Integer integer1 : collect1) {
            result.put(integer1, begin + 1);
        }
        doFilter(collect2, begin + 1, result);
    }

}
